Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

wip: example with deno #11

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

wip: example with deno #11

wants to merge 1 commit into from

Conversation

oliveriosousa
Copy link
Contributor

This PR is a WIP example of running IPFS using Deno.

Since js-ipfs uses CommonJS and Deno uses ESModule it is possible to have some compatibility with Node.JS but not every builtin is implemented and some are partly.

The std/node library

The std/node part of the Deno standard library is a Node.js compatibility layer. It's primary focus is providing "polyfills" for Node.js's built-in modules. It also provides a mechanism for loading CommonJS modules into Deno.

The library is most useful when trying to use your own or private code that was written for Node.js. If you are trying to consume public npm packages, you are likely to get a better result using a CDN.

Copied from Deno

When using this method, it throws the following error:

> example-ipfs-101-deno@1.0.0 start
> deno run --allow-read=node_modules --unstable --allow-env index.ts

error: Uncaught TypeError: Cannot read property 'RSA_PKCS1_PADDING' of undefined
const padding = crypto.constants.RSA_PKCS1_PADDING
                                 ^
    at Object.<anonymous> (file:///Users/oliveriosousa/Projects/PL/js-ipfs-examples/examples/ipfs-101-deno/node_modules/libp2p-crypto/src/keys/rsa.js:75:34)
    at Module._compile (https://deno.land/std@0.102.0/node/module.ts:168:36)
    at Object.Module._extensions..js (https://deno.land/std@0.102.0/node/module.ts:1123:10)
    at Module.load (https://deno.land/std@0.102.0/node/module.ts:147:34)
    at Function._load (https://deno.land/std@0.102.0/node/module.ts:413:14)
    at Module.require (https://deno.land/std@0.102.0/node/module.ts:133:21)
    at require (https://deno.land/std@0.102.0/node/module.ts:1172:16)
    at Object.<anonymous> (file:///Users/oliveriosousa/Projects/PL/js-ipfs-examples/examples/ipfs-101-deno/node_modules/libp2p-crypto/src/keys/rsa-class.js:12:16)
    at Module._compile (https://deno.land/std@0.102.0/node/module.ts:168:36)
    at Object.Module._extensions..js (https://deno.land/std@0.102.0/node/module.ts:1123:10)

Alternative

It is possible to also use JSPM which will convert NPM modules to ES Modules

When using this method, it throws the following error:

Import 'https://dev.jspm.io/npm:ipns@0.13.2/src/index.dew.js' failed: 500 Internal Server Error

@oliveriosousa oliveriosousa marked this pull request as draft August 2, 2021 16:56
@oliveriosousa oliveriosousa mentioned this pull request Aug 10, 2021
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant